
const layui = require("../layui/layui")
function onbuttonclick(idStr)
{
    if (typeof (window.Application.Enum) != "object") { // 如果没有内置枚举值
        window.Application.Enum = WPS_Enum
    }
    switch(idStr)
    {
        case "getLayui":{
                	// let SjbSh=Application.ActiveSheet.Item("数据表")
                	// let YcscjSh=Application.ActiveSheet.Item("原体质测试成绩")
                	// let SjbEnd=SjbSh.Cells(Rows.Count,4).End(xlUp);
                	// let YcscjShEnd=YcscjSh.Cells(Rows.Count,4).End(xlUp);
                	// let SgArr =YcscjSh.Range("d2",YcscjShEnd).Value2.flat();
                	// for(var 学籍号 of SjbSh.Range("D2",SjbEnd)){
                 //        var 查找结果=SgArr.indexOf(学籍号.Value2.replace(/\s*/g,""))+2;       
                 //        if (查找结果!=1){
                 //        	//Debug.Print(查找位置)
                 //        	 var SjbLarr=["J","K","T"];
                 //       		 var YcscjLarr=["J","K","R"]; 
                 //       		 for (var LarrNum in SjbLarr){
                 //       		 SjbSh.Range(SjbLarr[LarrNum]+学籍号.Row).Value2= YcscjSh.Range(YcscjLarr[LarrNum]+查找结果).Value2;
                 //       		 //Debug.Print(列数组1[列数组下标])
                 //       		 }
                 //       }
                	// }		
                	// 获取原等级()
                	// alert("导入原有体质数据完成")
					layui()

            }
        case "dockRight":{
            let tsId = window.Application.PluginStorage.getItem("taskpane_id")
                if (tsId){
                    let tskpane = window.Application.GetTaskPane(tsId)
                    tskpane.DockPosition = window.Application.Enum.msoCTPDockPositionRight
                }
                break
        }
        case "hideTaskPane":{
            let tsId = window.Application.PluginStorage.getItem("taskpane_id")
                if (tsId){
                    let tskpane = window.Application.GetTaskPane(tsId)
                    tskpane.Visible = false
                }
                break
        }
        case "addString":{
            let curSheet = window.Application.ActiveSheet;
            if (curSheet){
                curSheet.Cells.Item(1, 1).Formula="Hello, wps加载项!" + curSheet.Cells.Item(1, 1).Formula
            }
            break;
        }
        case "getDocName":{
            let doc = window.Application.ActiveWorkbook
                let textValue = "";
                if (!doc){
                    textValue = textValue + "当前没有打开任何文档"
                    return
                }
                textValue = textValue + doc.Name
                document.getElementById("text_p").innerHTML = textValue
                break
        }
    }
}

window.onload = ()=>{
    var xmlReq = WpsInvoke.CreateXHR();
    var url = location.origin + "/.debugTemp/NotifyDemoUrl"
    xmlReq.open("GET", url);
    xmlReq.onload = function (res) {
        var node = document.getElementById("DemoSpan");
        window.document.getElementById("DemoSpan").innerHTML = res.target.responseText;
    };
    xmlReq.send();
}